VERSION 5.00
Begin VB.Form Form1 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "RegExp Verification"
   ClientHeight    =   3090
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   11565
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   3090
   ScaleWidth      =   11565
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton Command2 
      Caption         =   "Clear"
      Height          =   615
      Left            =   9420
      TabIndex        =   6
      Top             =   1140
      Width           =   1935
   End
   Begin VB.TextBox txtResult 
      BeginProperty Font 
         Name            =   "Courier"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   1935
      Left            =   120
      MultiLine       =   -1  'True
      ScrollBars      =   3  'Both
      TabIndex        =   5
      Top             =   1020
      Width           =   8955
   End
   Begin VB.CommandButton Command1 
      Caption         =   "Verify"
      Height          =   615
      Left            =   9420
      TabIndex        =   4
      Top             =   1920
      Width           =   1935
   End
   Begin VB.TextBox txtString 
      Height          =   345
      Left            =   2640
      TabIndex        =   2
      Top             =   480
      Width           =   8835
   End
   Begin VB.TextBox txtPattern 
      Height          =   345
      Left            =   2640
      TabIndex        =   0
      Top             =   60
      Width           =   8835
   End
   Begin VB.Label Label1 
      Alignment       =   1  'Right Justify
      Caption         =   "String to Verify"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   60
      TabIndex        =   3
      Top             =   540
      Width           =   2535
   End
   Begin VB.Label lblA 
      Alignment       =   1  'Right Justify
      Caption         =   "Regular Exp. Pattern"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   60
      TabIndex        =   1
      Top             =   120
      Width           =   2535
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Dim regEx As RegExp

Private Sub Command1_Click()
    Dim myMatch As Match
    Dim myMatches As MatchCollection
    
    On Local Error GoTo TrapErr
    
1   regEx.Pattern = txtPattern.Text   ' Set pattern.
    
2   Set myMatches = regEx.Execute(txtString.Text)   ' Execute search.
3   txtResult.Text = "Number of matches: " & myMatches.Count & vbNewLine
    
4   For Each myMatch In myMatches   ' Iterate Matches collection.
       txtResult.Text = vbNewLine & txtResult.Text & "Match found at position " & myMatch.FirstIndex & ". Match Value is '" & myMatch.Value & "'." & vbNewLine
    Next
    Set myMatches = Nothing
    Exit Sub
TrapErr:
    txtResult.Text = "Error in verifying: " & Erl & vbNewLine & Err.Number & Space$(1) & Err.Description
End Sub

Private Sub Command2_Click()
    txtResult.Text = vbNullString
'    txtPattern.Text = vbNullString
'    txtString.Text = vbNullString
End Sub

Private Sub Form_Load()
    Set regEx = New RegExp      ' Create a regular expression.
    regEx.IgnoreCase = True     ' Set case insensitivity.
    regEx.Global = True         ' Set global applicability.
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Set regEx = Nothing
End Sub
